package com.stack.admin.feign;

import com.stack.admin.service.AdNewsService;
import com.stack.apis.admin.IAdminClient;
import com.stack.model.admin.dtos.AdNewsDto;
import com.stack.model.admin.pojos.AdNews;
import com.stack.model.common.dtos.ResponseResult;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class AdminNewsClient implements IAdminClient {

    @Resource
    private AdNewsService adNewsService;

    @PostMapping("/api/v1/AdCheckNews/save")
    @Override
    public ResponseResult saveAdCheckNews(@RequestBody AdNewsDto dto) {
        return adNewsService.saveAdCheckNews(dto);
    }

    @PostMapping("/api/v1/AdCheckNews/update")
    @Override
    public Boolean updateAdCheckNews(@RequestBody AdNewsDto adNewsDto) {
        AdNews adNews = new AdNews();
        BeanUtils.copyProperties(adNewsDto, adNews);
        return adNewsService.updateById(adNews);
    }
}
